// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   PhotoSensorView.java

package jones.gui;

import java.awt.*;
import java.util.Observable;
import java.util.Observer;
import javax.swing.*;
import jones.*;

public class PhotoSensorView extends JPanel
    implements Observer
{

    private JProgressBar leftLightMeter = null;
    private JProgressBar rightLightMeter = null;

    public PhotoSensorView()
    {
        leftLightMeter = new JProgressBar(1, 0, (int)PhotoSensor.MAX);
        rightLightMeter = new JProgressBar(1, 0, (int)PhotoSensor.MAX);
        JPanel labelPanel = new JPanel(((java.awt.LayoutManager) (new BorderLayout())));
        JLabel maxLabel = new JLabel(Integer.toString((int)PhotoSensor.MAX));
        maxLabel.setHorizontalAlignment(4);
        maxLabel.setVerticalAlignment(1);
        labelPanel.add(((java.awt.Component) (maxLabel)), "North");
        JLabel minLabel = new JLabel(Integer.toString(0));
        minLabel.setHorizontalAlignment(4);
        minLabel.setVerticalAlignment(3);
        labelPanel.add(((java.awt.Component) (minLabel)), "South");
        labelPanel.add(((java.awt.Component) (new JPanel())), "Center");
        add(((java.awt.Component) (labelPanel)));
        add(((java.awt.Component) (leftLightMeter)));
        add(((java.awt.Component) (rightLightMeter)));
        leftLightMeter.setPreferredSize(new Dimension(15, 40));
        leftLightMeter.setForeground(Color.yellow);
        rightLightMeter.setPreferredSize(new Dimension(15, 40));
        rightLightMeter.setForeground(Color.yellow);
    }

    public void update(Observable obs, Object obj)
    {
        final SimpleRobotInterface robot = (SimpleRobotInterface)obs;
        SwingUtilities.invokeLater(new Runnable() {

            public void run()
            {
                try
                {
                    leftLightMeter.setValue(robot.getLeftPhoto());
                    rightLightMeter.setValue(robot.getRightPhoto());
                }
                catch (ValueNotAvailableException ex) { }
            }

        }
);
        repaint();
    }


}
